package JET.physics;

import JET.physics.bodies.SpringBody;
import JET.geom.Vec2d;
import JET.physics.bodies.Body;

/**
 *
 * @author 057Ry
 */
public final class SBCollision
{
    public Body body1, body2;
    public Mass bodyApm;
    public Wall bodyBwall;
    public final Vec2d norm = new Vec2d();           // wektor normalny sciany bioracej udzial w kolizji
    public final Vec2d hitPt = new Vec2d();                // punkt udezenia masy w sciane w momencie kolizji
    public double edgeD;               // wspolczynnik odleglosci punktu udezenia na scianie (od v1 do v2)
    public double penetration;         // glebokosc penetracji sBody2 przez masę obiektu sBody1

    public final Vec2d vA = new Vec2d();
    public final Vec2d vB = new Vec2d();
    public final Vec2d vAB = new Vec2d();

    public SBCollision()
    {}

    public SBCollision(SpringBody sBody1, SpringBody sBody2, Mass bodyApm, Wall bodyBwall, Vec2d norm, Vec2d hitPt, double edgeD, double penetration) {
        this.body1 = sBody1;
        this.body2 = sBody2;
        this.bodyApm = bodyApm;
        this.bodyBwall = bodyBwall;
        this.norm.become(norm);
        this.hitPt.become(hitPt);
        this.edgeD = edgeD;
        this.penetration = penetration;
    }

    public void clear()
    {
        body1 = body2 = null;
        bodyApm = null;
        bodyBwall = null;
        norm.become(Vec2d.zero);
        hitPt.become(Vec2d.zero);
        edgeD = 0.;
        penetration = 0.;
        vA.become(Vec2d.zero);
        vB.become(Vec2d.zero);
        vAB.become(Vec2d.zero);
    }

    public void set(SBCollision col) {
        this.body1 = col.body1;
        this.body2 = col.body2;
        this.bodyApm = col.bodyApm;
        this.bodyBwall = col.bodyBwall;
        this.norm.become(col.norm);
        this.hitPt.become(col.hitPt);
        this.edgeD = col.edgeD;
        this.penetration = col.penetration;
        this.vA.become(col.vA);
        this.vB.become(col.vB);
        this.vAB.become(col.vAB);
    }
}